import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Demo {

    @Test
    public void T01() throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = format.parse("2020-1-1");

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(parse);
        Integer result = Calendar.getInstance().get(Calendar.MONTH) - calendar.get(Calendar.MONTH);
        System.out.println(result);
    }
}
